<template>
  <div class="tcy_404 container">
    <img src="@/assets/img/4.png">
    <h2>小笨蛋，页面跑偏啦～</h2>
    <p>你可以选择刷新页面或者返回主页</p>
    <a @click="toIndex" class="busy-btn busy-btn-primary busy-btn_blue">返回</a>
<!--    <a target="_blank" href="网站"/><li class="sidenav-btn"><font color='#FF7CACEE'>联系网站管理员</font>-->
  </div>
</template>

<script>
export default {

  mounted() {
    window.addEventListener('beforeunload', e => this.beforeunloadHandler(e))   //监听页面刷新触发事件
  },

  methods: {

    toIndex(){
      this.$router.push({path: '/'})
    },

    //根据事件进行操作进行操作
    beforeunloadHandler(e) {
      this.toIndex()
    },

  },
  destroyed () {  //进行监听销毁
    window.removeEventListener('beforeunload', e =>this.beforeunloadHandler(e))
  }
}
</script>
